<template>
	<view class="tabbar-container display-flex justify-around">
		<block>
			<view class="tabbar-item" v-for="(item,index) in tabbarList" :key="index"  :class="[item.centerItem ? ' center-item' : '']" @click="changeItem(item)">
				<view class="item-top">
					<image :src="currentItem==item.id?item.selectIcon:item.icon"></image>
				</view>
				<view class="item-bottom" :class="[currentItem==item.id ? 'item-active' : '']">
					<text>{{item.text}}</text>
				</view>
			</view>
		</block>

	</view>
</template>

<script>
	export default {
		props: {
			currentPage: {
				type: Number,
				default: 0
			}
		},
		data() {
			return {
				currentItem: 0,
				tabbarList: [{
						id: 0,
						path: "/pages/index/index",
						icon: this.config.HEALTHY_BABY,
						selectIcon: this.config.HEALTHY_BABY,
						text: "健康宝贝",
						centerItem: false
					},
					{
						id: 1,
						path: "/pages/education/index",
						icon: this.config.VITALITY_BABY,
						selectIcon: this.config.VITALITY_BABY,
						text: "活力宝贝",
						centerItem: false
					},
					{
						id: 3,
						path: "/pages/tutorial/tutorial",
						icon: this.config.CLEVER_BABY,
						selectIcon: this.config.CLEVER_BABY,
						text: "聪慧宝贝",
						centerItem: false
					},
					{
						id: 4,
						path: "/pages/personal/index",
						icon: this.config.CENTER_BABY,
						selectIcon: this.config.CENTER_BABY,
						text: "宝宝中心",
						centerItem: false
					}
				]

			};
		},
		mounted() {
			this.currentItem = this.currentPage;
			uni.hideTabBar();
		},
		methods: {
			changeItem(item) {
				console.log(item)
				// debugger
				let _this = this;
				//_this.currentItem = item.id;  
				uni.switchTab({
					url: item.path
				});
			}
		}
	}
</script>
<style>
	view {
		padding: 0;
		margin: 0;
		box-sizing: border-box;
	}

	.tabbar-container {
		position: fixed;
		bottom: 0;
		left: 0;
		width: 100%;
		height: 110rpx;
		box-shadow: 0 0 5px #999;
		display: flex;
		align-items: center;
		padding: 5rpx 0;
		color: #999999;
		background-color: #FFFFFF;
	}

	.tabbar-container .tabbar-item {
		width: 20%;
		height: 100rpx;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		text-align: center;
		margin-bottom: 60rpx;
	}

	.tabbar-container .item-active {
		color: #66B8A2;
	}

	.tabbar-container .center-item {
		display: block;
		position: relative;
	}

	.tabbar-container .tabbar-item .item-top {
		width: 65rpx;
		height: 88rpx;
	}

	.tabbar-container .center-item .item-top {
		flex-shrink: 0;
		width: 100rpx;
		height: 100rpx;
		position: absolute;
		top: -50rpx;
		left: calc(50% - 50rpx);
		border-radius: 50%;
		box-shadow: 0 0 5px #999;
		background-color: #ffffff;
	}

	.tabbar-container .tabbar-item .item-top image {
		width: 100%;
		height: 100%;
	}

	.tabbar-container .tabbar-item .item-bottom {
		font-size: 22rpx;
		width: 100%;
	}

	.tabbar-container .center-item .item-bottom {
		position: absolute;
		bottom: 5rpx;
	}
</style>
